package logic

import (
	"context"
	"sz2/C/rpc/good"

	"sz2/C/api/internal/svc"
	"sz2/C/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsShowLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGoodsShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsShowLogic {
	return &GoodsShowLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GoodsShowLogic) GoodsShow(req *types.GoodsShowRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	show, err := l.svcCtx.GoodRpc.GoodsShow(l.ctx, &good.GoodsShowRequest{Id: int64(req.Id)})
	if err != nil {
		return &types.Response{
			Msg:  err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Msg:  "详情展示成功",
		Code: 200,
		Data: show,
	}, nil
}
